package com.unicomcz.query;

import java.sql.ResultSet;
import java.text.SimpleDateFormat;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.apache.struts2.ServletActionContext;

import com.unicomcz.DetailPageAction;
import com.unicomcz.commision.CommDetailBean;
import com.unicomcz.commision.CommType;

public class DetailAlert extends DetailPageAction
{
    private String curAlertId;
    private String alertRemarks;
    /**
     * @return the curAlertId
     */
    public String getCurAlertId()
    {
        return curAlertId;
    }
    /**
     * @param curAlertId the curAlertId to set
     */
    public void setCurAlertId(String curAlertId)
    {
        this.curAlertId = curAlertId;
        HttpServletRequest request = ServletActionContext.getRequest();
        HttpSession session = request.getSession();
        List types = (List)session.getAttribute("ALERT");
        for (int i=0;i<types.size();i++) {
            AlertType ct = (AlertType)types.get(i);
            if (curAlertId.compareTo(ct.getAlertId())==0) {
                alertRemarks = ct.getAlertRemarks();
            }
        }
    }
    /**
     * @return the alertRemarks
     */
    public String getAlertRemarks()
    {
        return alertRemarks;
    }
    /**
     * @param alertRemarks the alertRemarks to set
     */
    public void setAlertRemarks(String alertRemarks)
    {
        this.alertRemarks = alertRemarks;
    }
    public String getSqlStr() {
        String sqlStr="SELECT depart_code 代理商,user_id 用户编号,serial_number 号码,open_date 开户时间,alert_id 佣金编号,alert_name 佣金名, "+
                     "product_id 套餐编号,product_name 套餐名,state_code 状态,sanwu_tag 是否3无,gprs_m GPRS费用,last_stop_time 话费,ycyf_fee 余额  "+
                     "  FROM dls_detail_alert "+
                     " WHERE depart_code = ?  AND alert_id=? order by open_date desc";
        return sqlStr;
    }
    public Object[] getParams() {
        return new Object[]{userInfo.getDepartCode(),curAlertId};
    }
    protected void regQueryParam() throws Exception{
        if ((acctMonth==null)||(acctMonth.length()==0)) {
            SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM");
            acctMonth=sf.format(new java.util.Date());
        }
        pstmt.setString(1, userInfo.getDepartCode());
        //pstmt.setString(2, acctMonth);
        pstmt.setString(2, curAlertId);
    }
    protected void rs2List(ResultSet rs,List out) throws Exception{
        AlertBean t = new AlertBean();
        t.setDepartId(rs.getString(1));
       // t.setAcctMonth(rs.getString(2));
       // t.setBrand(rs.getString(3));
      //  t.setBrandSub(rs.getString(4));
        t.setUserId(rs.getString(2));
        t.setSerialNumber(rs.getString(3));
        t.setOpenTime(rs.getString(4));
        t.setAlertId(rs.getString(5));
        t.setAlertName(rs.getString(6));
        t.setProductId(rs.getString(7));
        t.setProductName(rs.getString(8));
        t.setStatus(rs.getString(9));
        t.setFlag3W(rs.getString(10));
        t.setGprs(rs.getString(11));
        t.setLastStopTime(rs.getString(12));
        t.setYcyf(rs.getString(13));
      //  t.setHf(rs.getString(15));
      //  t.setCharge(rs.getString(16));
        out.add(t);
    }
    

}
